<template>
	<view>
		<web-view :src="src"></web-view>
	</view>
</template>

<script setup>
import {onLoad} from "@dcloudio/uni-app"
import { ref } from "vue"
import request from "@/common/request.js"

let src = ref("")
let loan_order_number = ref("");
onLoad((e) => {
	src.value = decodeURIComponent(e.url);
	loan_order_number.value = e.loan_order_number;
	setTimeout(() => {aaaaaa()}, 1200)
})
function aaaaaa() {
    let i = 0;
    let shouldStop = false;
    let intervalId; // 用于保存定时器的ID
    while (!shouldStop) {
        intervalId = setInterval(() => {
            if (i === 10) {
                shouldStop = true;
                uni.navigateBack({delta: 1});
                clearInterval(intervalId); // 清除定时器
                return;
            }
            request.post("api/pay/is_pay/", {"loan_order_number": loan_order_number.value })
               .then(res => {
                    console.log(res.data);
                    if (res.data.someCondition) {
                        shouldStop = true;
                        clearInterval(intervalId); // 清除定时器
                    }
                })
               .catch(err => {
                    console.error(err);
                    // 根据错误情况决定是否清除定时器等操作
                });
            i++;
        }, 1000);
    }
}
</script>

<style lang="scss">

</style>
